package com.zyguo.thread;

public class User {
	private int money;
	private int id;
	
	public User( int id ){
		this.setId(id);
	} 
	public int getMoney() {
		return money;
	}
	
	public synchronized int addMoney( int incrNum ){
		this.money = this.money + incrNum; 
		try {
			Thread.sleep( 3000 );
			System.out.println("addMoney, currThread=" + Thread.currentThread() );
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return this.money;
	}
	
	public synchronized int reducMoney( int reducNum ){
		this.money = this.money - reducNum;
		return this.money;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
}
